package com.study.springboottest.listener;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class MyListener implements HttpSessionListener {

    private Integer userNumber = 0;

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        userNumber++;
        se.getSession().setAttribute("userNumber", userNumber);
        System.out.println(userNumber);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        userNumber--;
        se.getSession().setAttribute("userNumber", userNumber);
        System.out.println(userNumber);
    }
}
